package isjinhao.jlox.grammar.statement;

import isjinhao.jlox.grammar.statement.represention.Statement;
import isjinhao.jlox.grammar.statement.visitor.StatementEvaluator;
import isjinhao.jlox.lexical.LoxScanner;
import isjinhao.jlox.lexical.TokenSequence;

/**
 * @Author ISJINHAO
 * @Date 2021/2/25 23:04
 */
public class StatementEvaluatorTest {

    public static void main(String[] args) {

        String expr = "{\n" +
                "\tvar name = \"ISJINHAO\";\n" +
                "\tname = \"浩天帝\";\n" +
                "\tprint name;\n" +
                "print (1 + 2) * ((4 / 2) / (2 - 1)) * (1.5 + 2.5);\n" +
                "\t{\n" +
                "\t\tname = \"詹金浩\";\n" +
                "\t\t{\n" +
                "\t\t\tprint name;\n" +
                "\t\t}\n" +
                "\t\tprint name;\n" +
                "\t}\n" +
                "\tprint name;\n" +
                "}";

        LoxScanner loxScanner = new LoxScanner(expr);
        TokenSequence tokenSequence = loxScanner.scanTokens();
        StatementParser statementParser = new StatementParser(tokenSequence);
        Statement statement = statementParser.parse();

        System.out.println(statement.toString());

        StatementEvaluator statementEvaluator = new StatementEvaluator();
        statementEvaluator.visit(statement);

    }

}
